<?php 
	include("header.php");
	include("top_menu.php");
?>
<title> Placed Devices </title>
<div class = "showdevices">
	<?php
		$connection = mysql_pconnect("localhost" , "root" , "31122001");
    	mysql_select_db("kt_site");
    	$query = "SELECT devices.id, devices.place, device_type.name FROM devices, device_type WHERE devices.type_id = device_type.id;";    	
		$sql = mysql_query($query);
		echo "<form name='deleteform' action = 'deletedevices.php' method = 'POST'>";
		echo "<div class = 'div-header div-header-sd'>";
		echo "<div id = 'div-header-sd-c1'> Device type </div>";
		echo "<div id = 'div-header-sd-c2'> Address </div>";
		echo "</div>";		
		for ($i = 0 ; $i < mysql_num_rows($sql) ; $i++) {
			$device = mysql_fetch_array($sql);			
			echo "<div class = 'div-row-sd'>";
			echo "<div id = 'div-row-sd-c1'> <input type = 'checkbox' name = 'devicestodelete[]' value = '".$device['id']."'></div>";
			echo "<div id = 'div-row-sd-c2'>".$device['name']."</div>";
			echo "<div id = 'div-row-sd-c3'>".$device['place']."</div>";		
			echo "</div>";
		}
		echo "<input type = 'submit' name = 'Delete' value = 'Delete choosen' class = 'button delete-button'>";
		echo "</form>";
	?>
</div>